CREATE TABLE VPI.PRE_DEPLOY_SCRIPT
(
	SERVICE_ID		VARCHAR2(32)				NOT NULL,
	VERSION_		NUMBER(4) DEFAULT 0			NOT NULL,
	OBJECT_NAME		VARCHAR2(61)				NOT NULL,
	OBJECT_TYPE		VARCHAR2(19) DEFAULT 'VIEW'	NOT NULL,
	OBJECT_SCRIPT	CLOB						NOT NULL,
	DEPLOY_ORDER	NUMBER(4)					NOT NULL,
	DEPLOY_STATUS	NUMBER(1) DEFAULT 0			NOT NULL,
	DEPLOY_ERROR	VARCHAR2(512),

	CONSTRAINT PK_PRE_DEPLOY_SCRIPT PRIMARY KEY (SERVICE_ID, VERSION_, OBJECT_NAME),
	CONSTRAINT FK_PRE_DEPLOY_SCRIPT FOREIGN KEY (SERVICE_ID, VERSION_) REFERENCES VPI.PRE_DEPLOY_VERSION (SERVICE_ID, VERSION_)
);

COMMENT ON TABLE VPI.PRE_DEPLOY_SCRIPT
	IS 'Script of deployment.';
-- Add comments to the columns 
COMMENT ON COLUMN VPI.PRE_DEPLOY_SCRIPT.SERVICE_ID
	IS 'The extract service (application) ID.';
COMMENT ON COLUMN VPI.PRE_DEPLOY_SCRIPT.VERSION_
	IS 'Version number of the extract service (application).';
COMMENT ON COLUMN VPI.PRE_DEPLOY_SCRIPT.OBJECT_NAME
	IS 'The object(view) name to be generated.';
COMMENT ON COLUMN VPI.PRE_DEPLOY_SCRIPT.OBJECT_TYPE
	IS 'Oject type (VIEW, etc).';
COMMENT ON COLUMN VPI.PRE_DEPLOY_SCRIPT.OBJECT_SCRIPT
	IS 'Deployment script of the object.';
COMMENT ON COLUMN VPI.PRE_DEPLOY_SCRIPT.DEPLOY_ORDER
	IS 'Deployment order.';
COMMENT ON COLUMN VPI.PRE_DEPLOY_SCRIPT.DEPLOY_STATUS
	IS '0 = Not deployed; 1 = Deployed Successfully; -1 = Deployed with Error.';
COMMENT ON COLUMN VPI.PRE_DEPLOY_SCRIPT.DEPLOY_ERROR
	IS 'Error message of deployment if fail';